package org.ala.tiktools.rpc.kcp.config;

/**
 * kcp相关配置
 *
 * @author ala
 * @date 2025-04-11 11:36
 */
public class RpcKcpConfigInfo {


    public static RpcKcpConfigInfo INSTANCE;


    /**
     *  服务端口号
     */
    protected int[] ports;
    /**
     * 	worker线程数
     */
    protected int workerCount;
    

    /****************************************************************************************************
     * udp 相关
     ****************************************************************************************************/
    /**
     *  recv端分配给每个ByteBuf的默认大小
     */
    protected int udpRecvBufferAllocateSize = 2048;
    /**
     *  还有数据没发送，但是要关闭的的channel，出发一次flush，延迟多少ms后再次触发close
     */
    protected int closeWaitTime = 5000;
    /**
     * 	send buffer大小（服务端）
     */
    protected int udpSendBufferSize = 64;
    /**
     * 	write 数据之后以多少概率执行一次flush
     */
    protected double udpSendFlushProb = 0.5d;


    /****************************************************************************************************
     *  kcp 相关
     ****************************************************************************************************/
    /**
     *  NoDelay模式下的最小rto
     */
    protected int iKcpRtoNdl = 30;
    /**
     *  最小rto
     */
    protected int iKcpRtoMin = 100;
    /**
     *  默认rto
     */
    protected int iKcpRtoDef = 200;
    /**
     *  最大rto
     */
    protected int iKcpRtoMax = 60000;


    /**
     *  发送滑窗大小（单位：Segment个数）
     */
    protected int iKcpWndSnd = 32;
    /**
     *  接收滑窗大小（必须大于frg（2子节）能表示的最大值）
     */
    protected int iKcpWndRcv = 128;


    /**
     *  单包（含头）最大长度（单位：字节）
     */
    protected int iKcpMtuDef = 1400;
    /**
     *  快速ack
     */
    protected int iKcpAckFast = 3;
    /**
     *  kcp间隔
     */
    protected int iKcpInterval = 100;
    /**
     *  重试错少次后宣布kcp链接无效
     */
    protected int iKcpDeadLink = 20;
    /**
     *  初始化阈值
     */
    protected int iKcpThreshInit = 2;
    /**
     *  最小阈值
     */
    protected int iKcpThreshMin = 2;
    /**
     *
     */
    protected int iKcpProbeInit = 7000;
    /**
     *
     */
    protected int iKcpProbeLimit = 120000;
    /**
     *  开启delay 模式
     */
    protected boolean iKcpNoDelay = false;
    /**
     *
     */
    protected int iKcpFastAckLimit = 3;
    /**
     * 立即刷新
     */
    protected boolean ikcpFastFlush = false;
    /**
     * 合并触发fireChannelRead
     */
    protected boolean ikcpMergeSegment = true;
    

    public int[] getPorts() {
		return ports;
	}

	public void setPorts(int[] ports) {
		this.ports = ports;
	}

	public int getiKcpRtoNdl() {
        return iKcpRtoNdl;
    }

    public void setiKcpRtoNdl(int iKcpRtoNdl) {
        this.iKcpRtoNdl = iKcpRtoNdl;
    }

    public int getiKcpRtoMin() {
        return iKcpRtoMin;
    }

    public void setiKcpRtoMin(int iKcpRtoMin) {
        this.iKcpRtoMin = iKcpRtoMin;
    }

    public int getiKcpRtoDef() {
        return iKcpRtoDef;
    }

    public void setiKcpRtoDef(int iKcpRtoDef) {
        this.iKcpRtoDef = iKcpRtoDef;
    }

    public int getiKcpRtoMax() {
        return iKcpRtoMax;
    }

    public void setiKcpRtoMax(int iKcpRtoMax) {
        this.iKcpRtoMax = iKcpRtoMax;
    }

    public int getiKcpWndSnd() {
        return iKcpWndSnd;
    }

    public void setiKcpWndSnd(int iKcpWndSnd) {
        this.iKcpWndSnd = iKcpWndSnd;
    }

    public int getiKcpWndRcv() {
        return iKcpWndRcv;
    }

    public void setiKcpWndRcv(int iKcpWndRcv) {
        this.iKcpWndRcv = iKcpWndRcv;
    }

    public int getiKcpMtuDef() {
        return iKcpMtuDef;
    }

    public void setiKcpMtuDef(int iKcpMtuDef) {
        this.iKcpMtuDef = iKcpMtuDef;
    }

    public int getiKcpAckFast() {
        return iKcpAckFast;
    }

    public void setiKcpAckFast(int iKcpAckFast) {
        this.iKcpAckFast = iKcpAckFast;
    }

    public int getiKcpInterval() {
        return iKcpInterval;
    }

    public void setiKcpInterval(int iKcpInterval) {
        this.iKcpInterval = iKcpInterval;
    }

    public int getiKcpDeadLink() {
        return iKcpDeadLink;
    }

    public void setiKcpDeadLink(int iKcpDeadLink) {
        this.iKcpDeadLink = iKcpDeadLink;
    }

    public int getiKcpThreshInit() {
        return iKcpThreshInit;
    }

    public void setiKcpThreshInit(int iKcpThreshInit) {
        this.iKcpThreshInit = iKcpThreshInit;
    }

    public int getiKcpThreshMin() {
        return iKcpThreshMin;
    }

    public void setiKcpThreshMin(int iKcpThreshMin) {
        this.iKcpThreshMin = iKcpThreshMin;
    }

    public int getiKcpProbeInit() {
        return iKcpProbeInit;
    }

    public void setiKcpProbeInit(int iKcpProbeInit) {
        this.iKcpProbeInit = iKcpProbeInit;
    }

    public int getiKcpProbeLimit() {
        return iKcpProbeLimit;
    }

    public void setiKcpProbeLimit(int iKcpProbeLimit) {
        this.iKcpProbeLimit = iKcpProbeLimit;
    }

    public int getiKcpFastAckLimit() {
        return iKcpFastAckLimit;
    }

    public void setiKcpFastAckLimit(int iKcpFastAckLimit) {
        this.iKcpFastAckLimit = iKcpFastAckLimit;
    }

    public boolean isiKcpNoDelay() {
        return iKcpNoDelay;
    }

    public void setiKcpNoDelay(boolean iKcpNoDelay) {
        this.iKcpNoDelay = iKcpNoDelay;
    }

    public int getUdpRecvBufferAllocateSize() {
        return udpRecvBufferAllocateSize;
    }

    public void setUdpRecvBufferAllocateSize(int udpRecvBufferAllocateSize) {
        this.udpRecvBufferAllocateSize = udpRecvBufferAllocateSize;
    }

    public int getCloseWaitTime() {
        return closeWaitTime;
    }

    public void setCloseWaitTime(int closeWaitTime) {
        this.closeWaitTime = closeWaitTime;
    }

	public int getUdpSendBufferSize() {
		return udpSendBufferSize;
	}

	public void setUdpSendBufferSize(int udpSendBufferSize) {
		this.udpSendBufferSize = udpSendBufferSize;
	}

	public double getUdpSendFlushProb() {
		return udpSendFlushProb;
	}

	public void setUdpSendFlushProb(double udpSendFlushProb) {
		this.udpSendFlushProb = udpSendFlushProb;
	}

	public int getWorkerCount() {
		return workerCount;
	}

	public void setWorkerCount(int workerCount) {
		this.workerCount = workerCount;
	}

	public boolean isIkcpFastFlush() {
		return ikcpFastFlush;
	}

	public void setIkcpFastFlush(boolean ikcpFastFlush) {
		this.ikcpFastFlush = ikcpFastFlush;
	}

	public boolean isIkcpMergeSegment() {
		return ikcpMergeSegment;
	}

	public void setIkcpMergeSegment(boolean ikcpMergeSegment) {
		this.ikcpMergeSegment = ikcpMergeSegment;
	}
}
